package logic

import (
	"context"
	"fmt"
	"medical-management-system/models/mysql"

	"medical-management-system/medicalrpc/internal/svc"
	"medical-management-system/medicalrpc/medicalrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelDoctorLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelDoctorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelDoctorLogic {
	return &DelDoctorLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DelDoctorLogic) DelDoctor(in *medicalrpc.DelDoctorRequest) (*medicalrpc.DelDoctorResponse, error) {
	// todo: add your logic here and delete this line
	var doctor mysql.Doctor
	err := mysql.DB.Debug().Where("id = ?", in.Id).Delete(&doctor).Error
	if err != nil {
		return nil, fmt.Errorf("删除失败")
	}
	return &medicalrpc.DelDoctorResponse{}, nil
}
